package com.zsk.config;

import java.time.LocalDateTime;

import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;

/**
 * 自动填功能配置
 * 
 * @author keke
 * @date 2020/07/24
 */
@Component
public class MyMetaObjectHandler implements MetaObjectHandler {

    /**
     * 新增增时更新的字段
     */
    @Override
    public void insertFill(MetaObject metaObject) {

        this.setInsertFieldValByName("createTime", LocalDateTime.now(), metaObject);
        this.setInsertFieldValByName("updateTime", LocalDateTime.now(), metaObject);

    }

    /**
     * 修改时更新的字段
     */
    @Override
    public void updateFill(MetaObject metaObject) {
        this.setUpdateFieldValByName("updateTime", LocalDateTime.now(), metaObject);

    }

}
